package string;

import java.util.Arrays;

/*
 * 1. 定义字符串String path = "http://localhost:8088/myweb/reg?name=zhangsan&pwd=123456&nick=san&age=16";
 *    要求得到并输出：参数名:name  参数值：zhangsan
 *                             参数名:pwd    参数值:  123456
 *                             参数名:nick     参数值: san
 *                             参数名:age      参数值: 16
 */
public class Test {
  /*  public static void main(String[] args) {
        String path = "http://localhost:8088/myweb/reg?name=zhangsan&pwd=123456&nick=san&age=16";
        String[] array1 = path.split("\\?");
        System.out.println("请求："+array1[0]);
        System.out.println("参数："+array1[1]);
        String[] array2 = array1[1].split("\\&");
        System.out.println(Arrays.toString(array2));
        for(int i = 0;i<array2.length;i++){
            String[] array3 = array2[i].split("=");
            System.out.println("name = "+array3[0]+",参数值 = "+array3[1]);
        }



    }*/
 /* public static void main(String[] args) {
      String line = "http://www.gdfg24.5353-/ffggsf?name=zhangsan&age=16&classname=jsd2302&stuid=001";
      String[] array1 = line.split("\\?");
      System.out.println("请求："+array1[0]);
      System.out.println("参数："+array1[1]);
      String[] array2 = array1[1].split("\\&");
      System.out.println(Arrays.toString(array2));
      for (int i = 0;i<array2.length;i++){
          String[] array3 = array2[i].split("=");
          System.out.println("参数名："+array3[0]+",参数值："+array3[1]);
      }

  }*/
  public static void main(String[] args) {
      String path = "http://www.localhost:8888.ff/fof332?name=zhangsan&age=16&class=jsd2302&address=8888";
      String[] array1 = path.split("\\?");
      System.out.println("请求："+array1[0]);
      System.out.println("参数："+array1[1]);
      String[] array2 = array1[1].split("\\&");
      for(int i = 0;i<array2.length;i++){
          String[] array3 = array2[i].split("=");
          System.out.println("参数名："+array3[0]+",参数值:"+array3[1]);
      }
  }
}
